/**
 * @a https://www.nowcoder.com/practice/acead2f4c28c401889915da98ecdc6bf
 */

#include "common.h"
using namespace std;

using ll = long long;
int main() {
    ll n,q; cin >> n >> q;
    vector<ll> dp(n + 1, 0);
    for(ll i = 1; i <= n; ++i)
    {
        ll tmp;
        cin >> tmp;
        dp[i] = tmp + dp[i - 1];
    }
    int l,r;
    while(q--)
    {
        cin >> l >> r;
        if(l <= r){
            cout << dp[r] - dp[l-1] << endl;
        }
    }
    return 0;
}